package logic

import (
	"context"
	"wechat1/wechat1rpc/wechat1rpc"

	"wechat1/wechat1api/internal/svc"
	"wechat1/wechat1api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type PerfectLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewPerfectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PerfectLogic {
	return &PerfectLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *PerfectLogic) Perfect(req *types.PerfectRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	perfect, err := l.svcCtx.Wechat1Rpc.Perfect(l.ctx, &wechat1rpc.PerfectRequest{
		Id:       req.Id,
		Mobile:   req.Mobile,
		Avatar:   req.Avatar,
		Nickname: req.Nickname,
		Address:  req.Address,
	})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: "完善错误",
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "完善成功",
		Data:    perfect.Id,
	}, nil
}
